﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <title>SignalR Raw Connection Sample</title>
    <style type="text/css">
        body {
            font-family: "Segoe UI";
            font-size: 12px;
        }
        form {
            margin-bottom: 10px;
            display: block;
        }
        label {
            display: block;
        }
    </style>
    <link rel="Stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" />
    <script src="../../Scripts/signalr.samples.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.12.4.min.js"></script>
    <script src="../../Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../Scripts/json2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.signalR.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-git.js"></script>
    <script>
        $(function () {
            "use strict";

            asyncTest('start', function () {
                var connection = $.connection('../../sending-connection', null, true);
                var messages = [];
                connection.received(function (message) {
                    messages.push(message);
                });

                connection.start({ transport: activeTransport, jsonp: isJsonp }).done(function () {
                    connection.send('blah');

                    setTimeout(function () {
                        start();
                        equal(messages.length, 10, 'All messages received');
                    }, 5000);
                });
            });

            asyncTest('jsonp-same-origin', function () {
                var connection = $.connection('../../sending-connection', null, true);
                var messages = [];
                connection.received(function (message) {
                    messages.push(message);
                });

                connection.start({ transport: 'longPolling', jsonp: true }).done(function () {
                    connection.send('blah');

                    setTimeout(function () {
                        start();
                        for (var i = 0; i < 10; i++) {
                            equal(messages[i], 'blah' + i, 'Message ' + i + ' successfully received', i);
                        }
                    }, 5000);
                });
            });
        });
    </script>
</head>
<body>
    <h1 id="qunit-header">
        QUnit example</h1>
    <h2 id="qunit-banner">
    </h2>
    <div id="qunit-testrunner-toolbar">
    </div>
    <h2 id="qunit-userAgent">
    </h2>
    <ol id="qunit-tests">
    </ol>
    <div id="qunit-fixture">
        test markup, will be hidden</div>
</body>
</html>
